import request from '@/utils/request';
import { getPageSize } from '@/utils/common';
/**
 * 查询配件报价列表
 */
export async function selectPartsOfferList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/tms/tms-parts-offer/selectTmsPartsOfferList`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 查询配件报价详情
 */
export async function selectPartsOfferDetail(params) {
  return request(`/server/api/tms/tms-parts-offer/viewTmsPartsOfferDetails`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 查询配件报价明细
 */
export async function selectPartsOfferInfo(params) {
  return request(`/server/api/tms/tms-parts-offer-relation/selectTmsPartsOfferDetailsList`, {
    method: 'POST',
    body: params,
  });
}

/**
 *  保存或者保存并提交
 */
export async function savePartsOffer(params) {
  const { id, ...rest } = params;
  const url = id ? 'updateTmsPartsOffer' : 'insertTmsPartsOffer';
  return request(
    `/server/api/tms/tms-parts-offer/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

/**
 *  保存或者保存并提交
 */
export async function savePartsOfferInfo(params) {
  const { id, ...rest } = params;
  const url = id !== -1 ? 'updateTmsPartsOfferRelation' : 'insertTmsPartsOfferRelation';
  return request(`/server/api/tms/tms-parts-offer-relation/${url}`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 查看配件详情
 */
export async function selectPartsDetail(params) {
  return request(`/server/api/tms/tms-parts-offer/viewTmsPartsDetails_s`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 删除明细
 */
export async function deletePartsInfo(params) {
  return request(`/server/api/tms/tms-parts-offer-relation/deleteTmsPartsOfferRelation`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 查询附件
 */
export async function selectFileList(params) {
  return request(`/server/api/tms/attachment/selectFileList`, {
    method: 'POST',
    body: params,
  });
}
